package 历年真题;

import java.util.Scanner;

/**
 * Created by stevenfenCai on 2017/4/6.
 */
public class q43 {

    /**
     * 获取和转换数据
     * @return
     */
    private static int[] getNum(){
        Scanner scanner = new Scanner(System.in);
        String string[] = scanner.nextLine().split(",");
        int i = 0;
        int num[] = new int[7];
        while(i < 7){
            num[i] = Integer.parseInt(string[i]);
            i++;
        }
        return num;
    }

    private static void fenjiu(int num1,int num2,int num3,int num[]){
        int b1 = num[1],c1 = num[2];
        int a = num1,b = num2,c = num3,result = num[6];
        if(b == result || c == result || a == result){
            System.out.println("");
        }else{
            /**
             * 12,8,5,12,0,0,6
             * 1.大瓶只能倒入小瓶
             * 2.中瓶只能倒入小瓶
             * 3.
             */
            if(c == c1){
                //只有小瓶子只有在已经装满的情况下才能倒入大瓶子
                a = a + c;
                c = 0;
                System.out.println(a + " " + b + " " + c);
                fenjiu(a,b,c,num);
            }else{
                if(c == 0 && b >0){
                    //若小瓶子被倒空，则无论中瓶子是否满，应马上从中瓶子倒入小瓶子
                    if(b > c1){
                        c = c1;
                        b = b - c1;
                        System.out.println(a + " " + b + " " + c);
                        fenjiu(a,b,c,num);
                    }else{
                        c = b;
                        b = 0;
                        System.out.println(a + " " + b + " " + c);
                        fenjiu(a,b,c,num);
                    }
                }else{
                    if(b!=b1){
                        a = a - b1 + b;
                        b = b1;
                        System.out.println(a + " " + b + " " + c);
                        fenjiu(a,b,c,num);
                    }else{
                        b = b - c1 + c;
                        c = c1;
                        System.out.println(a + " " + b + " " + c);
                        fenjiu(a,b,c,num);
                    }
                }
            }
        }
    }

    private static int gcd(int m,int n){
        int a = n,b = m;
        while(true){
            if((a = a % b) == 0)
                return b;
            if((b = b % a) == 0)
                return a;
        }
    }

    public static void main(String[] args){
        int num[] = getNum();
        int d = gcd(num[1],num[2]);    //中瓶和小瓶容量的最大公约数
        if(num[0]/2 <= num[1] + num[2] && (num[0]/2)%d == 0){
            System.out.println(num[3] + " " + num[4] + " " + num[5]);
            fenjiu(num[3],num[4],num[5],num);
        }else{
            System.out.println("不可能");
        }

    }
}
